package robotleMvc.ui.dispcontainer
{
	import com.net.AssetData;
	import com.ui.controls.Button;
	import com.ui.controls.Icon;
	import com.ui.data.ButtonData;
	import com.ui.data.IconData;
	import com.ui.skin.SkinStyle;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.utils.getTimer;
	
	import robotleMvc.frameworks.dispcontainer.DispcontainerEvent;
	import robotleMvc.ui.SkinType;
	
	public class DispcontainerView extends Sprite
	{
		private var _groundHightPic:Icon;
		private var _fpsinfo:TextField;
		private var _lastTime:int;
		public function DispcontainerView()
		{
			super();
			addBitmaps();
			addTexts();
			addButtons();
			addEvents();
			//addLines();

			
	
		}
		

		
		private function addLines():void
		{
		     var tempSprite:Sprite=new Sprite;
			 addChild(tempSprite);
			 tempSprite.graphics.beginFill(0xffcc55);
			 tempSprite.graphics.drawRect(0,300,1024,1);
			 tempSprite.graphics.drawRect(512,0,1,300);
			 tempSprite.graphics.endFill();
			
		}
		
		private function addEvents():void
		{
			
			_seeBtn.addEventListener(MouseEvent.CLICK,_seeBtnClik)
		}
		
		protected function _seeBtnClik(event:MouseEvent):void
		{
			var dispcontainerEvent:DispcontainerEvent=new DispcontainerEvent(DispcontainerEvent.CLIK_BUT);
			this.dispatchEvent(dispcontainerEvent)
			
		}
		private function addButtons():void
		{
			var data:ButtonData = new ButtonData();
			data.upAsset=new AssetData(SkinType.BUTTON_UP);
			data.downAsset=new AssetData(SkinType.BUTTON_DOWN);
			data.overAsset=new AssetData(SkinType.BUTTON_OVER);
			_seeBtn = new Button( data );
			_seeBtn.initToolTipManual();
			_seeBtn.toolTip.source="点击打开TOPMENUVIEW";
			_seeBtn.htmlText="控制面板"
			addChild( _seeBtn );
			_seeBtn.y=0;
			_seeBtn.x=200;
		}
		
		private function addTexts():void
		{
			_fpsinfo=new TextField()
			addChild(_fpsinfo);
			this.addEventListener(Event.ENTER_FRAME,enterFrame)
		}
		private var  _fNum:Number=0;
		private var _seeBtn:Button;
		private function enterFrame(evt:Event):void
		{
			var cc:int=getTimer()-_lastTime;
			_fNum++
			if(cc>=1000){
				_fpsinfo.htmlText="<font color='#ffffff' face='宋体'>fps: " + _fNum + "</font>";
				_fpsinfo.filters = [new GlowFilter(0x000000, 1, 2, 2, 17, 1, false, false)];
				_lastTime=getTimer();
				_fNum=0;
			}
		}
		
		private function addBitmaps():void
		{
			var icondata:IconData=new IconData;
			_groundHightPic=new Icon(icondata);
			addChild(_groundHightPic);

		}

		public function get groundHightPic():Icon
		{
			return _groundHightPic;
		}

		public function set groundHightPic(value:Icon):void
		{
			_groundHightPic = value;
		}

	}
}